//NC402
import java.util.;

注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
   public static void main(String[] args) {
       Scanner in = new Scanner(System.in);
       char[] arr = in.next().toCharArray();
       int max = 0;
       int[] tmp = new int[26];
       int len = arr.length;
       int count = 0;
       int r = 0;
       int l = 0;
       while(r  len) {
           tmp[arr[r]-'a']++; 
           if (tmp[arr[r]-'a'] == 1) {
               count++;
           }
           while (count  2) {
               tmp[arr[l]-'a']--;
               if (tmp[arr[l]-'a'] == 0) {
                   count--;
               }
               l++;
           }
           max = Math.max(r-l+1, max);
           r++;
       }
       System.out.println(max);
   }
}